package com.wz.project.executionphase.controller;

import com.wz.common.utils.poi.ExcelUtil;
import com.wz.device.entity.BasDeviceRecord;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.framework.web.page.TableDataInfo;
import com.wz.project.mydo.domain.MydoJob;
import com.wz.project.mydo.mydojob.service.IMydoJobService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备运行记录Controller
 * 
 * @author wld
 * @date 2023-04-04
 */
@Controller
@RequestMapping("/device/executionphase")
public class BasExecutionPhaseController extends BaseController
{
    private String prefix = "device/executionphase";

    @Autowired
    private IMydoJobService mydoJobService;

    @RequiresPermissions("device:executionphase:view")
    @GetMapping()
    public String record()
    {
        return prefix + "/executionphase";
    }

    /**
     * 查询设备运行记录列表
     */
//    @RequiresPermissions("device:executionphase:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MydoJob mydoJob)
    {

        List<MydoJob> list = mydoJobService.selectMydoJobTaskNo(mydoJob);
        return getDataTable(list);
    }


    /**
     * 新增设备运行记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }



    /**
     * 修改作业执行队列
     */
    @RequiresPermissions("device:executionphase:edit")
    @GetMapping("/edit/{jobId}")
    public String edit(@PathVariable("jobId") String jobId, ModelMap mmap)
    {
        MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(jobId);
        mmap.put("mydoJob", mydoJob);
        return prefix + "/edit";
    }

    /**
     * 修改保存作业执行阶段
     */
    @RequiresPermissions("device:executionphase:edit")
    @Log(title = "修改作业执行阶段", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MydoJob mydoJob)
    {
        return toAjax(mydoJobService.updateMydoJob(mydoJob));
    }


}
